home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1KOMIUC (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.2 KB  |  68 lines

  1. package sun.awt.image;
  2.  
  3. import java.awt.image.ImageConsumer;
  4.  
  5. class ImageConsumerQueue {
  6.    ImageConsumerQueue next;
  7.    ImageConsumer consumer;
  8.    boolean interested;
  9.    Object securityContext;
  10.    boolean secure;
  11.  
  12.    ImageConsumerQueue(InputStreamImageSource src, ImageConsumer ic) {
  13.       this.consumer = ic;
  14.       this.interested = true;
  15.       if (ic instanceof ImageRepresentation) {
  16.          ImageRepresentation ir = (ImageRepresentation)ic;
  17.          if (ir.image.source != src) {
  18.             throw new SecurityException("ImageRep added to wrong image source");
  19.          }
  20.  
  21.          this.secure = true;
  22.       } else {
  23.          SecurityManager security = System.getSecurityManager();
  24.          if (security != null) {
  25.             this.securityContext = security.getSecurityContext();
  26.          } else {
  27.             this.securityContext = null;
  28.          }
  29.       }
  30.  
  31.    }
  32.  
  33.    static boolean isConsumer(ImageConsumerQueue cqbase, ImageConsumer ic) {
  34.       for(ImageConsumerQueue cq = cqbase; cq != null; cq = cq.next) {
  35.          if (cq.consumer == ic) {
  36.             return true;
  37.          }
  38.       }
  39.  
  40.       return false;
  41.    }
  42.  
  43.    static ImageConsumerQueue removeConsumer(ImageConsumerQueue cqbase, ImageConsumer ic, boolean stillinterested) {
  44.       ImageConsumerQueue cqprev = null;
  45.  
  46.       for(ImageConsumerQueue cq = cqbase; cq != null; cq = cq.next) {
  47.          if (cq.consumer == ic) {
  48.             if (cqprev == null) {
  49.                cqbase = cq.next;
  50.             } else {
  51.                cqprev.next = cq.next;
  52.             }
  53.  
  54.             cq.interested = stillinterested;
  55.             break;
  56.          }
  57.  
  58.          cqprev = cq;
  59.       }
  60.  
  61.       return cqbase;
  62.    }
  63.  
  64.    public String toString() {
  65.       return "[" + this.consumer + ", " + (this.interested ? "" : "not ") + "interested" + (this.securityContext != null ? ", " + this.securityContext : "") + "]";
  66.    }
  67. }
  68.